package com.herdsric.common.core.exception;

import cn.hutool.core.util.StrUtil;
import lombok.Getter;

public class HerdsricBizException extends RuntimeException {

	private static final long serialVersionUID = 1L;

	@Getter
	private String code;
	@Getter
	private String msg;

	public HerdsricBizException(ErrorCodeEnum errorCode) {
		this(errorCode.code, errorCode.msg);
	}

	public HerdsricBizException(ErrorCodeEnum errorCode, String... params) {
		this(errorCode.code, errorCode.msg, params);
	}

	public HerdsricBizException(String format,ErrorCodeEnum errorCode,  String... params) {
		this(errorCode.code, StrUtil.format(format, params));
	}

	public HerdsricBizException(String code, String format, String... params) {
		this(code, StrUtil.format(format, params));
	}

	public HerdsricBizException(String code, String msg) {
		super(code + "," + msg);
		this.code = code;
		this.msg = msg;
	}
}
